import { ApiCall } from "tsrpc";
import { ReqRunCode, ResRunCode } from "../../shared/protocols/RunCode/PtlRunCode";
import { run2 } from "../../utils/runcode/docker";
import { CodeType } from '../../utils/runcode/utils/type';

export default async function (call: ApiCall<ReqRunCode, ResRunCode>) {
    // TODO
    const { code,type,stdin } = call.req

    const ret  = await run2({
        type:type as CodeType,
        code,
        stdin
    })

    console.log(ret);

    call.succ({
        ret:ret as {
            code:number,
            message:string,
            output:string,
            time:number
        }
    })
}